<?php include_once("../../../common/common_setting_unit.php");         // 引入通用的设置文件 ?>
<?php include_once(ROOT_PATH_ . "/controller/common/module/head.php"); // 引入通用的头部 ?>
<?php include_once("../controller/data_list.php");                     // 当前页面的控制器 ?>



<body>

<!--顶部栏-->
<div id="topbar"> <?php include ROOT_PATH_ . '/controller/common/module/topbar.php'; ?></div>

<!--容器-->
<div id="container" class="<? echo $now_extender ?>">

    <!--侧边栏-->
    <div id="sidebar"><?php include ROOT_PATH_ . '/controller/common/module/sidebar.php'; ?></div>





    <?
    //==============================================================================
    //这里开始才是平常开发需要注重的部分，其余的基本不用理会
    //==============================================================================
    ?>




<div id="content">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend><h1><? echo $sys_title ?> 分类列表</h1></legend>
    </fieldset>




<div class="list-box <? echo $system_part ?>">



    <hr/>
    <div class="statistic">
        <?php include_once("../module/term_btn.php");?>

        <div class="function">

            <div class="sort layui-form">
                <div class="layui-form-item" style="margin-bottom:5px;">
                    <label class="layui-form-label">排序：</label>
                    <div class="layui-input-block">
                        <select lay-filter="MM_jumpMenu">
                            <option value="">排序选择</option>
                            <option value="term-list.php?nowpageid=<?php echo $nowpageid; ?>&&sortby=listorder&&sortorder=desc&now_extender=<? echo $system_part ?>">人工排序降序</option>
                            <option value="term-list.php?nowpageid=<?php echo $nowpageid; ?>&&sortby=listorder&&sortorder=asc&now_extender=<? echo $system_part ?>">人工排序升序</option>
                            <option value="term-list.php?nowpageid=<?php echo $nowpageid; ?>&&sortby=nid&&sortorder=desc&now_extender=<? echo $system_part ?>">输入时间降序</option>
                            <option value="term-list.php?nowpageid=<?php echo $nowpageid; ?>&&sortby=nid&&sortorder=asc&now_extender=<? echo $system_part ?>">输入时间升序</option>
                            <option value="term-list.php?nowpageid=<?php echo $nowpageid; ?>&&sortby=name&&sortorder=desc&now_extender=<? echo $system_part ?>">资料名称升序</option>
                            <option value="term-list.php?nowpageid=<?php echo $nowpageid; ?>&&sortby=name&&sortorder=asc&now_extender=<? echo $system_part ?>">资料名称降序</option>
                        </select>
                    </div>
                </div>
            </div>


        </div>


        <hr/>
    </div>


<style>
    .list-boxes .layui-table tr td .date span{padding-right: 15px;}
    .list-boxes .layui-table .name{margin-top: 15px;}
</style>

<div class="list-boxes term-list-box">


    <table class="layui-table">
        <colgroup>

            <col width="100">
            <col width="250">
            <col>
            <col>
            <col>
            <col>
            <col width="300">
        </colgroup>
        <thead>
        <tr>
            <th>编号</th>
            <th>图片</th>
            <th>分类名称</th>
            <th>发布状态</th>
            <th>点击次数</th>
            <th>数据量</th>
            <!-- <th>资料</th> -->
            <th>操作</th>
        </tr>
        </thead>
        <tbody>

        <?php
		
        for($i=0;$i<$term0num;$i++)
        {
			
			$cat_list = implode(',',get_cat_child($term0[$i]['nid'],$system_part));
			
			$result = mysql_query("select count(*) as number from ".$table_Prefix."relation where term_nid in ($cat_list)");

			$now_product_number = mysql_fetch_assoc($result);
			
        ?>
        <tr>
        <td ><?echo $i+1?></td>
            <td align="center">             
                    <img src="../../uploadfiles/<?echo $theme_folder?>/<?php echo $term0[$i]['icon'] ?>" width="50"/>
                </td>
            <!-- 分类名称 -->
            <td>
                <a href="term-edit.php?nid=<?php echo $term0[$i]['nid'] ?>&now_extender=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term0[$i]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                    <span><?php echo $term0[$i]['name'] ?></span>
                </a>
            </td>
            <!-- 发布状态 -->
            <td>
                <span class="publish <? if($term0[$i]['publish']!=1){echo "title-notice";} ?>">
                    <? if ($term0[$i]['publish']==1){echo "是";} else {echo "否";} ?>
                </span>
            </td>
            <!-- 点击次数 -->
            <td>
                <span class="clickrate">
                    <? echo $term0[$i]['clickrate'] ?>
                </span>
            </td>
            <!-- 产品数量 -->
            <td>
                <span class="product_number">
                    <a href="view/data_list.php?now_extender=product&nid=<?php echo $term0[$i]['nid'] ?>">
                        <? echo $now_product_number['number'] ;?>
                    </a>
                </span>
            </td>

            <!-- <td>
                <div class="name" style="margin-bottom: 15px;">
                    <label>分类名称：</label>
                    <a href="term-edit.php?nid=<?php echo $term0[$i]['nid'] ?>&now_extender=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term0[$i]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                        <span style="font-size: 18px"><?php echo $term0[$i]['name'] ?></span>
                    </a>
                </div>


<div class="date">
				<? if( $term0[$i]['modifytime']){ ?>
                <span class="modifytime">
                    <label>修改时间：</label><? echo $term0[$i]['modifytime'] ?>
                </span>
                <?php }?>
                <span class="publish <? if($term0[$i]['publish']!=1){echo "title-notice";} ?>">
                    <label>发布状态：</label><? if ($term0[$i]['publish']==1){echo "是";} else {echo "否";} ?>
                </span>
                <span class="clickrate">
                    <label>点击次数：</label><? echo $term0[$i]['clickrate'] ?>
                </span>
                <span class="product_number">
                    <label>产品数量：</label>
				
                    <a href=" data_list.php?now_extender=product&nid=<?php echo $term0[$i]['nid'] ?>">
                   
					<? 
					echo $now_product_number['number'] ;
					?>
                    </a>
                </span>
</div>
            </td> -->

            <td>
            
                <a  class="delete layui-btn  layui-btn-sm"  <?php if($term0[$i]['is_disabled'] == 1 || $now_product_number['number'] > 0){echo 'style= background:#ccc;cursor:not-allowed; '.' href="javascript:void(0)"';}else{ echo 'href="term-delete.php?nid='. $term0[$i]['nid'].'&now_extender='. $system_part.'"';}?> ><i class="layui-icon">&#xe640;</i>删除</a>
                <a href="term-edit.php?nid=<?php echo $term0[$i]['nid'] ?>&now_extender=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" class="modify layui-btn  layui-btn-sm"><i class="layui-icon">&#xe642;</i>修改</a>
                <a class="weixin-miniapp-code layui-btn  layui-btn-sm" onclick="getWXCode(this)" data-nid="<?php echo $term0[$i]['nid'] ?>" data-name="<?php echo $term0[$i]['name'] ?>"> <i class="layui-icon">&#xe677;</i> 小程序码</a>
                <input type="button" class="layui-btn  layui-btn-sm huanqiao-sync-term" data-nid="<?php echo $term0[$i]['nid'] ?>" value=" 同步此分类">
            </td>
        </tr>
        
         <?

        //设置需要搜索的表格的前缀后缀
        $table_Suffix=$sys_term_table;
        $table=$table_Prefix.$table_Suffix;
        //设置需要搜索的表格的前缀后缀


        //设置需要搜索的表格的排序项和升降项
        $sort_by = "nid";
        $sort_order = "desc";
        //设置需要搜索的表格的排序项和升降项

        ?>
         <?

        $query2 = mysql_query("SELECT COUNT(nid) FROM $table where term1 = ".$term0[$i]['nid']." && interm = 'term1' and belong = '$sys_belong'");
        $term1sum = mysql_result($query2, 0);
	
        if ($_REQUEST ['sortby'])
        {
            $sort_by = $_REQUEST ['sortby'];
        }

        $result1 = mysql_query("select * from $table where term1 = ".$term0[$i]['nid']." && interm = 'term1' and belong = '$sys_belong' ORDER BY $sort_by $sort_order");

		$term1 = array();
        while($row1 = mysql_fetch_assoc($result1))
        {
          	$term1[] = $row1;
            $term1_icon[$i][]=$row1['icon'];

        }
		

        ?>
        <?php 
		
		
		
		for($ii=0;$ii<$term1sum;$ii++){
			
			$cat_list = implode(',',get_cat_child($term1[$ii]['nid'],$system_part));
			
			$result = mysql_query("select count(*) as number from ".$table_Prefix."relation where term_nid in ($cat_list)");

			$now_product_number2 = mysql_fetch_assoc($result);
				
		?>
        <tr>
        <td ><?echo ($i+1).'-'.($ii+1) ?></td>
             <td align="center">             
                    <img src="../../uploadfiles/<?echo $theme_folder?>/<?php echo $term1[$ii]['icon'] ?>" width="50"/>
                </td>

                <!-- 分类名称 -->
                <td>
                    <a href="term-edit.php?nid=<?php echo $term1[$ii]['nid'] ?>&now_extender=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term1[$ii]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                        <span><?php echo $term0[$i]['name'] ?> - <?php echo $term1[$ii]['name'] ?></span>
                    </a>
                </td>
                <!-- 发布状态 -->
                <td>
                    <span class="publish <? if($term1[$ii]['publish']!=1){echo "title-notice";} ?>">
                        <? if ($term1[$ii]['publish']==1){echo "是";} else {echo "否";} ?>
                    </span>
                </td>
                <!-- 点击次数 -->
                <td>
                    <span class="clickrate">
                        <? echo $term1[$ii]['clickrate'] ?>
                    </span>
                </td>
                <!-- 产品数量 -->
                <td>
                    <span class="product_number">
                        <a href="view/data_list.php?now_extender=product&nid=<?php echo $term1[$ii]['nid'] ?>">
                            <?  echo $now_product_number2['number'] ;?>
                        </a>
                    </span>
                </td>

            <!-- <td>
                <div class="name" style="margin-bottom: 15px;">
                    <label>分类名称：</label>
                    <a href="term-edit.php?nid=<?php echo $term1[$ii]['nid'] ?>&now_extender=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term1[$ii]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                        <span style="font-size: 18px"><?php echo $term0[$i]['name'] ?> - <?php echo $term1[$ii]['name'] ?></span>
                    </a>
                </div>


<div class="date">
				<? if($term1[$ii]['modifytime']){ ?>
                <span class="modifytime">
                    <label>修改时间：</label><? echo $term1[$ii]['modifytime'] ?>
                </span>
                <?php }?>
                <span class="publish <? if($term1[$ii]['publish']!=1){echo "title-notice";} ?>">
                    <label>发布状态：</label><? if ($term1[$ii]['publish']==1){echo "是";} else {echo "否";} ?>
                </span>
                <span class="clickrate">
                    <label>点击次数：</label><? echo $term1[$ii]['clickrate'] ?>
                </span>
                <span class="product_number">
                    <label>产品数量：</label>
                    <a href=" data_list.php?now_extender=product&nid=<?php echo $term1[$ii]['nid'] ?>">
                   
					<? 
					echo $now_product_number2['number'] ;
					?>
                    </a>
					
                </span>
</div>
            </td> -->

            <td>
            
                <a  class="delete layui-btn  layui-btn-sm"  <?php if($term1[$ii]['is_disabled'] == 1 || $now_product_number2['number'] > 0){echo 'style= background:#ccc;cursor:not-allowed; '.' href="javascript:void(0)"';}else{ echo 'href="term-delete.php?nid='. $term1[$ii]['nid'].'&now_extender='. $system_part.'"';}?> ><i class="layui-icon">&#xe640;</i>删除</a>
                <a href="term-edit.php?nid=<?php echo $term1[$ii]['nid'] ?>&now_extender=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" class="modify layui-btn  layui-btn-sm"><i class="layui-icon">&#xe642;</i>修改</a>
                <input type="button" class="layui-btn  layui-btn-sm huanqiao-sync-term" data-nid="<?php echo $term0[$i]['nid'] ?>" value=" 同步此分类">
            </td>
        </tr>
        	<?

			$term1idnow=$term1[$i]['nid'];
	
			$query = mysql_query("SELECT COUNT(nid) FROM $table where term2 = $term1idnow && interm = 'term2' and belong = '$sys_belong'" );
			$term2sum = mysql_result($query, 0);
	
	
			$result2 = mysql_query("select * from $table where term2= $term1idnow && interm = 'term2' and belong = '$sys_belong' ORDER BY $sort_by $sort_order");
	
			$term2 = array();
			while($row2 = mysql_fetch_assoc($result2))
			{
				
				$term2_icon[]=$row2['icon'];
				$term2[]=$row2;
			
			}
			
			?>
             <?php 
			 for($iii=0;$iii<$term2sum;$iii++){ 
			 	$cat_list = implode(',',get_cat_child($term2[$iii]['nid'] ,$system_part));
			
				$result = mysql_query("select count(*) as number from ".$table_Prefix."relation where term_nid in ($cat_list)");
	
				$now_product_number3 = mysql_fetch_assoc($result);
			 ?>
            <tr>
            <td ><?echo ($i+1).'-'.($ii+1).'-'.($iii+1) ?></td>
             <td align="center">             
                    <img src="../../uploadfiles/<?echo $theme_folder?>/<?php echo $term2[$i]['icon'] ?>" width="50"/>
                </td>

                <!-- 分类名称 -->
                <td>
                    <a href="term-edit.php?nid=<?php echo $term2[$iii]['nid'] ?>&now_extender=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term2[$iii]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                        <span><?php echo $term0[$i]['name'] ?> - <?php echo $term1[$ii]['name'] ?> - <?php echo $term2[$iii]['name'] ?></span>
                    </a>
                </td>
                <!-- 发布状态 -->
                <td>
                    <span class="publish <? if($term2[$iii]['publish']!=1){echo "title-notice";} ?>">
                        <? if ($term2[$iii]['publish']==1){echo "是";} else {echo "否";} ?>
                    </span>
                </td>
                <!-- 点击次数 -->
                <td>
                    <span class="clickrate">
                        <? echo $term2[$iii]['clickrate'] ?>
                    </span>
                </td>
                <!-- 产品数量 -->
                <td>
                    <span class="product_number">
                        <a href="view/data_list.php?now_extender=product&nid=<?php echo $term2[$iii]['nid'] ?>">
                            <?  echo $now_product_number3['number'] ; ?>
                        </a>
                    </span>
                </td>

            <!-- <td>
                <div class="name" style="margin-bottom: 15px;">
                    <label>分类名称：</label>
                    <a href="term-edit.php?nid=<?php echo $term2[$iii]['nid'] ?>&now_extender=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" <? if ($term2[$iii]['publish'] != 1) { echo "class='title-notice'"; } ?> >
                        <span style="font-size: 18px"><?php echo $term0[$i]['name'] ?> - <?php echo $term1[$ii]['name'] ?> - <?php echo $term2[$iii]['name'] ?></span>
                    </a>
                </div>


<div class="date">
				<? if( $term2[$iii]['modifytime']){ ?>
                <span class="modifytime">
                    <label>修改时间：</label><? echo $term2[$iii]['modifytime'] ?>
                </span>
                <?php }?>
              
                <span class="publish <? if($term2[$iii]['publish']!=1){echo "title-notice";} ?>">
                    <label>发布状态：</label><? if ($term2[$iii]['publish']==1){echo "是";} else {echo "否";} ?>
                </span>
                
                <span class="clickrate">
                    <label>点击次数：</label><? echo $term2[$iii]['clickrate'] ?>
                </span>
                
                <span class="product_number">
                    <label>产品数量：</label>
                    <a href=" data_list.php?now_extender=product&nid=<?php echo $term2[$iii]['nid'] ?>">
                   
					<? 
					echo $now_product_number3['number'] ;
					?>
                    </a>
                </span>
               
</div>
            </td> -->

            <td>
            
                <a  class="delete layui-btn  layui-btn-sm"  <?php if($term2[$iii]['is_disabled'] == 1 || $now_product_number3['number'] > 0){echo 'style= background:#ccc;cursor:not-allowed; '.' href="javascript:void(0)"';}else{ echo 'href="term-delete.php?nid='. $term2[$iii]['nid'].'&now_extender='. $system_part.'"';}?> ><i class="layui-icon">&#xe640;</i>删除</a>
                <a href="term-edit.php?nid=<?php echo $term2[$iii]['nid'] ?>&now_extender=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>" class="modify layui-btn  layui-btn-sm"><i class="layui-icon">&#xe642;</i>修改</a>
                <a class="weixin-miniapp-code layui-btn  layui-btn-sm" onclick="" data-nid="<?php echo $detail_nid[$i] ?>" data-name="<?php echo $detail_name[$i] ?>"> <i class="layui-icon">&#xe677;</i> 小程序码</a>
                <input type="button" class="layui-btn  layui-btn-sm huanqiao-sync-term" data-nid="<?php echo $term0[$i]['nid'] ?>" value=" 同步此分类">
            </td>
        </tr>
        <?php 
			}
		}
	
	} ?>
       
	 	</tbody>
    </table>

</div>


<div class="list-box-function" <? if ($term0num==0){echo "style"."='display:none'";} ?> >
    <div class="page-guide">

        <?php
        if($nowpageid==1)
        {
            ?>
            <!--现在页数在第一页的时候-->
            <span>首页</span>
            <span>前一页</span>
            <!--现在页数非第一页的时候-->
        <?php
        }
        else
        {
            ?>
            <!--现在页数非第一页的时候-->
            <a href="term-list.php?sortby=<?php echo $sort_by; ?>&nid=<?php echo $trans_nid ?>&now_extender=<? echo $system_part ?>">首页</a>
            <a href="term-list.php?nowpageid=<?php echo $prepage; ?>&sortby=<?php echo $sort_by; ?>&nid=<?php echo $trans_nid ?>&now_extender=<? echo $system_part ?>">前一页</a>
            <!--现在页数非第一页的时候-->
        <?php
        }
        ?>


        <!--开始列印出所有页码-->

        <?php
        $ii=1;
        $iii=1;
        while ($ii<=$page_count)
        {
            //首先判断是不是当前页

            if($ii==$nowpageid)
            {
                echo "<span>".$ii."</span>";
            }
            else if((($ii+5)<$nowpageid)||(($ii-5)>$nowpageid))
            {
            }
            else
            {
                echo "<a href='";
                echo "term-list.php?nowpageid=";
                echo $iii;
                echo "&sortby=";
                echo $sort_by;
                echo "&nid=";
                echo $trans_nid;
                echo "&now_extender=";
                echo $system_part;
                echo "'>";
                echo $iii;
                echo "</a>";
            }

            $ii++;
            $iii++;
        }
        ?>

        <!--列印出所有页码 结束-->


        <?php
        if($nowpageid==$page_count)
        {
            ?>
            <!--现在页数在第一页的时候-->
            <span>后一页</span>
            <span>末页</span>
            <!--现在页数非第一页的时候-->
        <?php
        }
        else
        {
            ?>
            <!--现在页数非第一页的时候-->
            <a href="term-list.php?nowpageid=<?php echo $nextpage; ?>&sortby=<?php echo $sort_by; ?>&nid=<?php echo $trans_nid ?>&now_extender=<? echo $system_part ?>">后一页</a>
            <a href="term-list.php?nowpageid=<?php echo $lastpage; ?>&sortby=<?php echo $sort_by; ?>&nid=<?php echo $trans_nid ?>&now_extender=<? echo $system_part ?>">末页</a>
            <!--现在页数非第一页的时候-->
        <?php
        }
        ?>




    </div>
    <!--翻页代码结束-->
</div>


<!--list-box end-->
</div>

<!--content端點01-->
</div>

</div>
<!--content端點01-->
<?
//==============================================================================
//这里上面才是平常开发需要注重的部分，下面的基本不用理会，只有底部JS部分需要根据实际情况去加载
//==============================================================================
?>





<br class="clearfloat"/>
<!--container-->
</div>




<!--底部栏-->
<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?>


<!--载入删除功能-->
<script type="text/javascript" src="/controller/common/asset/js/deleter.js"></script>


</body>
</html>